<?php

class Thumb
{
    public static function getThumb($imagedata, $type, $ratio)
    {
		$size = $ratio;

		$image = imagecreatefromstring ($imagedata);

		$width = imagesx ($image);
		$height = imagesy ($image);
		$modwidth = $width * $size;
		$modheight = $height * $size;
		$thumbImage = imagecreatetruecolor($modwidth, $modheight) ;
		imagecopyresampled($thumbImage, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;
		if ($type == 'image/jpeg')
			imagejpeg ($thumbImage);
		if ($type == 'image/png')
			imagepng ($thumbImage);
		if ($type == 'image/gif')
			imagegif ($thumbImage);
		imagedestroy ($thumbImage);
		imagedestroy ($image);
    }

}

?>